package com.controller;

import java.util.Enumeration;

import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import javax.servlet.http.HttpSessionContext;

import org.springframework.http.HttpRequest;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import com.uedu.manager.StudentManager;
import com.uedu.vo.Student;

@Controller
public class LoginController {
	
	@RequestMapping("/login")
	public String login(String 	stu_number,String stu_passwd,HttpServletRequest request){
		
		boolean flag = false;
		
		Student student = new Student(stu_number,stu_passwd);
		
		StudentManager studentManager = new StudentManager();
		
		flag = studentManager.login(student);
		
		if(flag==true){
			/*
			model.addAttribute("stu_number", student.getStu_number());
			model.addAttribute("stu_sex", student.getStu_sex());
			model.addAttribute("stu_name", student.getStu_name());*/
			HttpSession session = request.getSession();
			session.setAttribute("student",student);		
			return "success";
			
		}else{
			return "fail";
		}
		
		
	}
	
}
